<template>
  <div class="tree-node">
    <ul class="tree-ul">
      <li class="tree-li" @click="handleExpand">
        <span class="tree-open-indicator"></span>
        <input v-if="checked" type="checkbox" v-model="checkbox">
        <!-- <render v-if="render" :render="render" :data="noodData" :node="node"/> -->
        <span class="tree-title">{{noodData.name}}</span>
        <Tree-node
          v-if="!laoding"
          v-for="(item, i) in children"
          :key="i"
          :noodData="item">
        </Tree-node>
      </li>
    </ul>
  </div>
</template>

<script type="text/ecmascript-6">
import render from './render'
export default {
  name: 'TreeNode',
  props: {
    noodData: {
      type: Object,
      default: function () {
        return {}
      }
    },
    checked: {
      type: Boolean,
      default: false
    },
    render: {
      type: Function
    },
    laoding: {
      type: Boolean,
      default: false
    }
  },
  components: {
    render
  },
  computed: {
    children () {
      return this.noodData.children ? this.noodData.children : []
    },
    node () {
      return []
    }
  },
  methods: {
    handleExpand () {
      this.laoding = true
    }
  }
}
</script>

<style scoped>
.tree-ul,.tree-li{
  list-style: none;
  padding: 0;
  margin: 0;
}
.tree-li {
  color: #f00;
  cursor: pointer;
  text-align: left;
  font-weight: bold;
  box-sizing: border-box;
  padding: 0 20px;
  background: rgb(230, 217, 34);
}
.tree-title {
  min-width: 150px;
  height: 30px;
  line-height: 30px;
  display: inline-block
}
.tree-open-indicator {
  width: 0;
  height: 0;
  display: inline-block;
  margin-bottom: 2px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #fff;
}
</style>
